package com.pms.config;

import jakarta.annotation.PostConstruct;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConfigurationProperties(prefix = "tianditu")
@Data
public class LocationConfig {
    private String key; // 天地图Web服务API的key
    private Double workplaceLatitude; // 工作地点纬度
    private Double workplaceLongitude; // 工作地点经度
    private Integer allowedDistance; // 允许打卡的距离范围(米)
    // 添加配置校验
    @PostConstruct
    public void validateConfig() {
        if (workplaceLatitude == null || workplaceLongitude == null) {
            throw new IllegalStateException("工作地点坐标未配置，请检查配置文件");
        }
        if (allowedDistance == null) {
            allowedDistance = 1000; // 设置默认值
        }
    }
}